<?php 
    include 'function.php'; 
    
    $bits = getParam("bits");
    $is_clear = getParam("is_clear");
    $errorBinaryChecker = getParam("errorBinaryChecker");
    $errorBinary = getParam("errorBinary");
    
    if ($is_clear == 0) {
        $errors = null;
        if (strcmp($errorBinaryChecker,$errorBinary) == 0) {
            $result = generateChecksBits($bits, $errorBinaryChecker);
            $errorBinaryChecker = implode($result['errorBinaryChecker']);
            generateHammingCodeTable($bits, $errorBinaryChecker);
        } else {
            $result = validateInput($errorBinaryChecker, $errorBinary);
            if (!$result['return']) {
                errorPage($result['error']); 
                exit;
            } 
            $result = generateChecksBits($bits, $errorBinaryChecker, $errorBinary);
            $errorBinary = implode($result['errorBinary']);
            $errorBinaryChecker = implode($result['errorBinaryChecker']);
            $array_diff = $result['array_diff'];
            generateHammingCodeTable($bits, $errorBinaryChecker, $errorBinary, $array_diff);
        }
        /*if (!is_null($errors)) {
            echo "Error : ".$errors;
        }*/
    } 
